import { Button, Form } from 'antd'
import { ModalForm, ProForm, ProFormDateTimePicker, ProFormText } from '@ant-design/pro-components'
import { ProZoomModalForm } from '@zoom-design/zoom-design-demo'
import I18n from '/@/wms/locale/locale.tsx'
import { ModalTypeProps } from '/@/wms/types/ModalTypeProps.tsx'

const TypeModal = (props: ModalTypeProps) => {
  const [form] = Form.useForm<any>()
  const { record, title, tableActionRef } = props
  const { t } = I18n.i18n
  return <>
    <ModalForm
      // @ts-ignore
      labelWidth="auto"
      width={'30%'}
      title={<>{t(`${title}`)}</>}
      trigger={<Button type="primary">{t(`${title}`)}</Button>}
      form={form}
      modalProps={{
        destroyOnClose: true
      }}
      onFinish={async values => {
        console.log(values)
        const modelValue = { ...record, ...values }
        console.log('modelValue', modelValue)
        console.log('tableActionRef', tableActionRef)
        tableActionRef?.current?.reload()
        return true
      }}
    >
      <ProForm.Group>
        <ProFormText
          width="xl"
          name="typeKey"
          label={'键名称'}
          tooltip={t('最长为 24 位')}
          placeholder="请输入名称"
          initialValue={record?.typeKey}
        />
        <ProFormText
          width="xl"
          name="typeValue"
          label={'键值'}
          tooltip={t('最长为 24 位')}
          placeholder="请输入名称"
          initialValue={record?.typeValue}
        />
        <ProFormText
          width="xl"
          name="parentKey"
          label={'父键'}
          disabled={true}
          tooltip={t('最长为 24 位')}
          placeholder="请输入名称"
          initialValue={record?.parentKey}
        />
        <ProFormText
          width="xl"
          name="sort"
          label={'排序'}
          tooltip={t('最长为 24 位')}
          placeholder="请输入名称"
          initialValue={record?.sort}
        />
        <ProFormText
          width="xl"
          name="typeDesc"
          label={'描述'}
          tooltip={t('最长为 24 位')}
          placeholder="请输入名称"
          initialValue={record?.typeDesc}
        />
      </ProForm.Group>
    </ModalForm>
  </>

}

export default TypeModal